'use strict';

import React from "react";
import {Image, Platform, StyleSheet, View} from "react-native";
import Global from "./Model/Global/GCPublic";
import GCStyle from "./Model/Global/GCStyle";
import Home from "./TabBar";
import Login from "./View/AboutMe/Account/Login";
class Splash extends React.Component {
    constructor(props) {
        super(props);
    }

    componentDidMount() {

        const {
            navigator
        } = this.props;
        setTimeout(() => {
            if (Global.User.token == null || Global.User.token == '') {
                navigator.resetTo({
                    component: Login,
                    name: 'Login',
                });
            } else {
                navigator.resetTo({
                    component: Home,
                    name: 'Home',
                });
            }

        }, 500);
    }

    randomNum(Min, Max) {
        var Range = Max - Min;
        var Rand = Math.random();
        return (Min + Math.round(Rand * Range));
    }

    render() {
        return (
            <View style={{flex: 1, backgroundColor: 'white', alignItems: 'center'}}>
                <Image source={require('./Resource/Imgs/splash.png')} style={styles.coverimage}/>
            </View>
        );
    }
}

const styles = StyleSheet.create({
    coverimage: {
        width: GCStyle.GCPubWidth,
        height: GCStyle.GCPubHeight,
    },
});
export default Splash;